<?php
namespace App\Pay\Gateway\Alipay;

class WebGateway extends Gateway
{

    /**
     * @param $payload array
     */
    public function pay($payload)
    {
        $payload['method'] = $this->getMethod();
        $bizContent = is_array($payload['biz_content']) ? $payload['biz_content'] : json_decode($payload['biz_content'], true);
        $bizContent['product_code'] = 'FAST_INSTANT_TRADE_PAY';
        $payload['biz_content'] = json_encode($bizContent, JSON_UNESCAPED_UNICODE);
        $payload['sign'] = Sign::get($payload);
        return Request::url() . '?' . (http_build_query($payload));
    }



    public function getMethod(): string
    {
        return 'alipay.trade.page.pay';
    }
}
